<!DOCTYPE HTML>
<html>
<head>
    <title>短租预订</title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
</head><%
    'use strict';
let orderData = {
    state : data.orderStatus
};
let orderState = {
    OS00: '待确认',
    OS01: '待支付',
    OS02: '已支付',
    OS03: '已取消',
    OS04: '已取消',
}

%><body ontouchstart="" style="padding-bottom: 45px;height:auto;">
<div class="weui_panel weui_panel_access">
    <div class="weui_panel_bd">
        <div class="weui_media_box weui_media_text" style="padding: 1rem;">
            <p style="font-weight:700;font-size: 0.7rem;color: #141414;margin-bottom: 0.2rem"><%= data.shortDesc %></p>
            <p class="weui_media_desc"><%= data.name %></p>
            <div class="orderState orderState-<%=data.orderStatus%>"><%= orderState[data.orderStatus] %></div>
        </div>
    </div>
</div>

<div class="weui_cells_title">预订信息</div>
<div class="weui_cells" style="font-size: 0.7rem;">
    <div class="weui_cell">
        <div class="weui_cell_bd">
            <p>预订人：</p>
        </div>
        <div class="weui_cell_ft">
            <%=userData.name%>
        </div>
    </div>
    <div class="weui_cell">
        <div class="weui_cell_bd">
            <p>手机号：</p>
        </div>
        <div class="weui_cell_ft">
            <%=userData.phone%>
        </div>
    </div>
    <div class="weui_cell">
        <div class="weui_cell_bd">
            <p>入住方式：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.orderType%>
        </div>
    </div>
    <div class="weui_cell">
        <div class="weui_cell_bd">
            <p>住宿时间：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.arrivedDate.substring(5)%>至
            <%= data.leavedDate.substring(5)%>(<%= data.leavedDate.substring(0,4)%>)
        </div>
    </div>
    <% if(data.house.beds.length > 0 ){%>
    <div class="weui_cell">
        <div class="weui_cell_bd">
            <p>床数量：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.house.beds.length %>
        </div>
    </div>
    <% } %>
    <!--<div class="weui_cell">
        <div class="weui_cell_bd">
            <p>支付方式：</p>
        </div>
        <div class="weui_cell_ft">
            支付宝
        </div>-->
    </div>
</div>

<div class="weui_cells_title">房间信息</div>
<div class="weui_cells" style="font-size: 0.7rem;">
    <div class="weui_cell">
        <div class="weui_cell_bd">
            <p>面积：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.area %>平方米
        </div>
    </div>
    <div class="weui_cell">
        <div class="weui_cell_bd">
            <p>地址：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.house.myAddress %>
        </div>
    </div>
    <div class="weui_cell">
        <div class="weui_cell_bd ">
            <p>楼层：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.house.floor %>层
        </div>
    </div>
</div>
<div class="weui_panel house_description">
    <div class="weui_panel_bd">
        <%- data.uedit %>
    </div>
</div>

<div class="weui_cells_title">备注信息</div>
<div class="weui_cells" style="font-size: 0.7rem;">
    <div class="weui_cell">
        订单备注
    </div>
    <div class="weui_cell">
        <%= data.remark%>
    </div>
</div>
<div class="weui_cells_title">入住需知</div>
<div class="weui_cells" style="font-size: 0.7rem;">
    <div class="weui_cell">
        <% include common/houseInfo.ejs %>
    </div>
</div>

<div class="bottomBar">
    <table class="bottomTable">
        <tbody>
            <tr>
                <td>
                    <span class="bottomInfo">总额 <span class="color-warning">￥<%= data.rentPrice%></span></span>
                    <span class="bottomRemark">查看明细</span>
                </td>
                <% if(orderData.state == 'OS01'){ %>
                <td style="width:100px;">
                    <a href="wepayShort?id=<%= data.id %>" class="weui_btn weui_btn_primary">立即支付</a>
                </td>
                <td style="width:100px;">
                    <a href="javascript:void(0)" class="weui_btn weui_btn_warn">取消订单</a>
                </td>
                <% }else if(orderData.state == 'OS00'){ %>
                <td style="width:100px;">
                    <a href="javascript:void(0)" class="weui_btn weui_btn_warn orderCancel"><input type="hidden" value="<%= data.id %>">取消订单</a>
                </td>
                <% }else if(orderData.state == 'OS02'){ %>
                <div>
                    <td style="width:100px;">
                        <a href="shortRentReserved?houseId=<%= data.house.id %>&openId=<%= session.openId %>&flag=1" class="weui_btn weui_btn_warn">续住</a>
                    </td>
                    <td style="width:100px;">
                        <a href="javascript:void(0)" class="weui_btn weui_btn_primary" id="showPassword">查看密码</a>
                    </td>
                    <td style="width:100px;">
                        <a href="javascript:void(0)" class="weui_btn weui_btn_warn" id="advance"><input type="hidden" value="<%= data.id %>">退房</a>
                    </td>
                </div>
                <% }else if(orderData.state == 'OS03'){ %>
                <td style="width:100px;">
                    <a href="javascript:void(0)" class="weui_btn weui_btn_primary" id="showPassword">查看密码</a>
                </td>
                <% } %>
            </tr>
        </tbody>
    </table>
</div>
<% include common/footer.ejs %>
<script src="<%= global.config.publicPath %>/Swiper/3.3.1/js/swiper.jquery.<%= global.config.mode %>js"></script>
<script>
    "use strict";
    $(function () {
        $("#submitBtn").click(function () {
//            let data = Dolphin.form.getValue("#reservedForm");
//            data.arrivedDate = data.arrivedDate+" 00:00:00";
//            data.leavedDate = data.leavedDate+" 00:00:00";
//            data.checkRoomDate = data.checkRoomDate+" 00:00:00";
//            console.log(data);
//            Dolphin.ajax({
//                url:CTX+'/api/f266ff4abe8d42bcb86931f7acc827be',
//                type:'put',
//                forceUrl:'true',
//                data: Dolphin.json2string(data),
//                onSuccess:function () {
//                    location.href = CTX+"/view/account";
//                }
//            });
        });


        <% if(orderData.state == 'OS02'){ %>
        $('#showPassword').click(function () {
            /*$.prompt("请输入预订人手机号", function(text) {
                //点击确认后的回调函数
                //text 是用户输入的内容
                if(text == '123456'){
                    $.alert("648362",'房间密码');
                }else{
                    $.alert("手机号错误",'系统提示');
                }
            }, function() {
                //点击取消后的回调函数
            });*/
            alert("此功能暂未开通");
        })
        <% } %>

        //取消订单
        $('.orderCancel').click(function () {
            var id = $(this).children().val();
            let flag = confirm('取消订单？');
            if (flag) {
                console.log(id);
                Dolphin.ajax({
                    url:CTX+'/api/779f87ff15fb4966ad97976b1f8aed63@id='+id,
                    type:Dolphin.requestMethod.GET,
                    forceUrl: 'true',
                    onSuccess: function (reData) {
                        alert("订单已取消  3秒后跳转至我的短租预定");
                        setTimeout(function () {
                            location.href = CTX+"/view/myShortRent";
                        }, 3000);
                    }
                });
            }
        });
        //提前退房
        $('#advance').click(function () {
            var id = $(this).children().val();
            let flag = confirm('提前退房？');
            if (flag) {
                console.log(id);
                Dolphin.ajax({
                    url:CTX+'/api/e42ad9a6eb584b5c88cbdfa00ee06122@id='+id,
                    type:Dolphin.requestMethod.GET,
                    forceUrl: 'true',
                    onSuccess: function (reData) {
                        alert("已提前退房  3秒后跳转至我的短租预定");
                        setTimeout(function () {
                            location.href = CTX+"/view/myShortRent";
                        }, 3000);
                    }
                });
            }
        });
    })

</script>
</body>
</html>